home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / exec.swg / 0016_DOS Windowed Ouput.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-01-27  |  2.3 KB  |  112 lines

  1. {
  2.    Norbert Igl
  3.    Fido    : 2:243/8301.3
  4.    Gernet  : 21:100/40.3
  5.    Internet: q3976866@fernuni-hagen.de
  6.  
  7. > I seen some code posted here a few weeks ago. I meant to save it,
  8. > but didn't. The code creates a windowed DOS shell.
  9. > I would like to simply run a .BAT installation file in a window
  10. > from my pascal program.
  11.  
  12.  ...same question a few days ago here in our local echo ... (:-)
  13.  Its not only with windowed output ( easy possible )
  14.  but also stores the pgm's output in your pgm's buffer ....
  15.  have fun!
  16. }
  17.  
  18. program test29;  {$M $1000,0,$FFF0}{ $C <Norbert Igl '93> }
  19. uses    crt, dos;
  20. const   maxBufSize = 64000;
  21.         old29  : pointer = nil;
  22. type    tVBuff = record
  23.                     siz : word;
  24.                     last: word;
  25.                     txt : array[1..MaxBufSize] of char;
  26.                  end;
  27.         pVBuff = ^tVBuff;
  28. var     Buf    : pVBuff;
  29.  
  30. procedure New29(Flags, CS, IP, AX,
  31.                 BX,CX, DX, SI, DI,
  32.                 DS, ES, BP: Word);  interrupt;
  33. begin
  34.   if Buf <> NIL then
  35.   with Buf^ do
  36.   begin
  37.     if last < siz then inc( Last );
  38.     txt[last] := CHAR(AX)
  39.   end
  40. end;
  41.  
  42. procedure BeginCapture;
  43. begin
  44.   if Old29 = NIL then  getintvec($29, Old29);
  45.   SetIntVec($29, @New29 );
  46. end;
  47.  
  48. procedure DoneCapture;
  49. begin
  50.   if old29 <> Nil then
  51.   begin
  52.     SetIntVec($29, old29);
  53.     old29 := NIL
  54.   end
  55. end;
  56.  
  57. procedure InitBuffer;
  58. begin
  59.   Buf    := NIL
  60. end;
  61.  
  62. procedure BeginBuffer(Size:word);
  63. begin
  64.   if Size > maxBufSize then size := maxBufSize;
  65.   GetMem( Buf, Size );
  66.   Buf^.siz := Size;
  67.   Buf^.last:= 0;
  68.   fillchar( Buf^.txt, size-4, 0);
  69. end;
  70.  
  71. procedure DoneBuffer;
  72. begin
  73.   if Buf <> NIL then
  74.   begin
  75.     dispose(buf);
  76.     initBuffer;
  77.   end
  78. end;
  79.  
  80. procedure ShowBuffer;
  81. var i, maxy : word;
  82. begin
  83.   if buf = NIL then exit;
  84.   maxy := (WindMax - WindMin) shr 8;
  85.   clrscr;
  86.   for i := 1 to Buf^.last do
  87.   begin
  88.     if wherey = maxy then
  89.     begin
  90.       write(' --- weiter mit Taste --- '); clreol;
  91.       readkey;
  92.       clrscr;
  93.     end;
  94.     write( buf^.txt[i] );
  95.   end;
  96.   write(#13#10' --- Ende, weiter mit Taste --- '); clreol;
  97.   readkey;
  98.   clrscr;
  99. end;
  100.  
  101. begin
  102.   InitBuffer;
  103.   BeginBuffer($4000); { 16k Buffer, max=64k }
  104.   BeginCapture;
  105.   swapvectors;
  106.   exec( getenv('comspec'),' /C DIR *.pas');
  107.   swapvectors;
  108.   DoneCapture;
  109.   ShowBuffer;
  110.   DoneBuffer
  111. end.
  112.